package openmind.demo.basicUsage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wangzhuangzhuang
 * @DESC: forEach和Lambda中的return使用
 * @date 2022-01-01 22:13
 */
public class ClassicDemo01 {
	public static void main(String[] args) {
		List<String> data = Arrays.asList("1", "2", "3");
		data.forEach(d -> {
			if ("2".equals(d)) {
				return;
			}
			System.out.println("element's name[02style] : " + d);
		});

		for (int i = 0; i < data.size(); i++) {
			if ("2".equals(data.get(i))) {
				return;
			}
			System.out.println("element's name[01style] : " + data.get(i));
		}
	}
}

//element's name[02style] : 1
//element's name[02style] : 3
//element's name[01style] : 1